$(function() {
  resize();
  window.onresize = function() {
    resize();
  }
})

function resize() {
  var bodyWidth = document.documentElement.clientWidth;
  var bodyHeight = document.documentElement.clientHeight;
  var rate = 1920 / 1080, realRate = bodyWidth / bodyHeight;
  var scaleRate = 1, scaleHeight = 0, scaleWidth = 0;
  if (realRate < rate) { // 高度大
    scaleRate = bodyWidth / 1920;
    scaleWidth = bodyWidth;
    scaleHeight = bodyWidth / rate;
  } else { // 宽度大
    scaleRate = bodyHeight / 1080;
    scaleHeight = bodyHeight;
    scaleWidth = rate * bodyHeight;
  }
  $('body').css('height', scaleHeight + 'px');
  $('body').css('width', scaleWidth + "px");
  $('.main-container').css('transform', 'scale(' + scaleRate + ')');
  $('.main-container').css('-webkit-transform', 'scale(' + scaleRate + ')');
  $('.main-container').css('-moz-transform', 'scale(' + scaleRate + ')');
  $('.main-container').css('-ms-transform', 'scale(' + scaleRate + ')');
  $('.main-container').css('-o-transform', 'scale(' + scaleRate + ')');
}
